package com.central.player.model;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Data
public class PlayerBase extends Player {


    /**
     * 手机号码
     */
    private String phone;

    public void setPhone(String phone) {
        this.phone = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 玩家类型:
     */
    private Integer type;

    /**
     * 是否在线
     */
    private Integer online;

    public void setOnline(Date loginOn, Date logoutOn) {
        if (loginOn.getTime() > logoutOn.getTime() || logoutOn == null)
            this.online = 1;
        else
            this.online = 0;
    }

//    public PlayerBase(String phone, String nickName, Integer type, Integer online, Date loginOn, Date logoutOn) {
//        super();
//        this.phone = phone;
//        this.nickName = nickName;
//        this.type = type;
//        this.online = online;
//        this.loginOn = loginOn;
//        this.logoutOn = logoutOn;
//    }

    private Date loginOn;
    private Date logoutOn;

    @Override
    public String toString() {
        super.toString();
        return "PlayerBase{" + "phone='" + phone + '\'' + ", nickName='" + nickName + '\'' + ", type=" + type + ", online=" + online + '}';
    }
}
